New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ariesclark/array

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ariesclark/array

Fast, efficient, and easy-to-use array extensions for TypeScript.

  • 0.2.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source
@ariesclark/array logo

Fast, efficient, and easy-to-use array extensions for TypeScript.

Packages

@ariesclark/extensions @ariesclark/array @ariesclark/number @ariesclark/object @ariesclark/string

Installation

npm install @ariesclark/extensions
# Or directly, if you only need the array extension.
npm install @ariesclark/array

Documentation

group (function)

Groups the items in the array by the given function.

group([1, 2, 3, 4, 5], item => (item % 2 === 0 ? 'even' : 'odd'));
// {
//   odd: [1, 3, 5],
//   even: [2, 4]
// }

randomIndex (function)

Get a random index from an array, with an optional random number generator.

Parameters:

  • array ({ length: 0; })
  • random (RandomFunction)

returns: null

const value = ['lorem', 'ipsum', 'dolor', 'sit', 'amet'];

randomIndex(value); // 3, eventually.
randomIndex(value); // 0, eventually.
randomIndex(value); // 2, eventually.

randomIndex (function)

Parameters:

  • array ({ length: number; })
  • random (RandomFunction)

returns: null

randomIndex (function)

Parameters:

  • array ({ length: number; })
  • random (RandomFunction)

returns: null

randomItem (function)

Get a random item from an array, with an optional random number generator.

Parameters:

  • array ({ length: 0; })
  • random (RandomFunction)

returns: null

const value = ['lorem', 'ipsum', 'dolor', 'sit', 'amet'];

randomItem(value); // "amet", eventually.
randomItem(value); // "dolor", eventually.
randomItem(value); // "lorem", eventually.

randomItem (function)

Parameters:

  • array ({ [index: number]: T; length: number; })
  • random (RandomFunction)

returns: null

randomItem (function)

Parameters:

  • array ({ [index: number]: T; length: number; })
  • random (RandomFunction)

returns: null

unique (function)

Returns a new array with unique values based on the by function.

Parameters:

  • array (T[])
  • by ((value: T) => unknown)

returns: T[]

{ from, fromAsync, isArray, of } (variable)

Keywords

FAQs

Package last updated on 01 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc